﻿//Copyright (c) Microsoft Corporation.  All rights reserved.

namespace Universe.TaskBarManager
{
    using System;
    using System.Drawing;

    internal static class WindowUtilities
    {
        internal static Point GetParentOffsetOfChild(IntPtr hwnd, IntPtr hwndParent)
        {
            var childScreenCoord = new CoreNativeMethods.POINT(0, 0);

            TabbedThumbnailNativeMethods.ClientToScreen(
                hwnd, ref childScreenCoord);

            var parentScreenCoord = new CoreNativeMethods.POINT(0, 0);

            TabbedThumbnailNativeMethods.ClientToScreen(
                hwndParent, ref parentScreenCoord);

            var offset = new Point(
                childScreenCoord.X - parentScreenCoord.X,
                childScreenCoord.Y - parentScreenCoord.Y);

            return offset;
        }

        internal static Size GetNonClientArea(IntPtr hwnd)
        {
            var c = new CoreNativeMethods.POINT(0, 0);

            TabbedThumbnailNativeMethods.ClientToScreen(hwnd, ref c);

            var r = new CoreNativeMethods.RECT();

            TabbedThumbnailNativeMethods.GetWindowRect(hwnd, ref r);

            return new Size(c.X - r.left, c.Y - r.top);
        }
    }
}